$(document).ready(function(){
	  $("#set-option").unbind("click");
	  
	   /*display lang*/
	   var lang = $("#display-lang").val();
	   var selector = "input[name=display-langs][value="+lang+"]";
	   $(selector).attr("checked","checked");
	   
	   /*leftnav */
	   $("a.d").addClass("nav-select");
	   $(".leftnav a").mouseover(function(){
		   $(this).addClass("bh");
	   });
	   $(".leftnav a").mouseout(function(){
		   $(this).removeClass("bh");
	   }); 
	   $(".leftnav a").click(function(){
		   if(!$(this).hasClass("nav-select")){
			   $(".leftnav a.nav-select").each(function(){
				   $(this).removeClass("nav-select");
			   });
			   $(this).addClass("nav-select");
			   if($(this).hasClass("c")){
				   $(".lang-display-set").hide();
				   $(".lang-prefer-set").show();
			   }else{
				   $(".lang-display-set").show();
				   $(".lang-prefer-set").hide();
			   }
		   }
	   });
	   
	   $("#displayLangbuttons .sbutton").click(function(){
		   var from = $("#f");
		   if(from.length>0){
			   var location = from.val();
			   if($("input[name=display-langs]:checked").val()=="zh"){
				      if(location.indexOf("?")==-1){
		                 location=location+"?lang=zh" ;
				      }else 
				    	  location=location+"&lang=zh" ;
	           }else if($("input[name=display-langs]:checked").val()=="en"){
	        	      if(location.indexOf("?")==-1){
		                 location=location+"?lang=en" ;
	        	      }else
	        	    	  location=location+"&lang=en" ; 
	           }
			   window.location=location;
		   }else{
			   var location = WEBAPP+"views/index.jsp" ;
			   if($("input[name=display-langs]:checked").val()=="zh"){
	                 location=location+"?lang=zh" ;
               }
			   window.location=location;
		   }
	   });
	   
	   $("#displayLangbuttons .cbutton").click(function(){
		   var from = $("#f");
		   if(from.length>0){
			   var location =from.val();
			   if(lang=="zh"){
				   if(location.indexOf("?")==-1){
					   location=location+"?lang=zh" ;
				   }else{
					   location=location+"&lang=zh" ;
				   }
	           }else if(lang=="en"){
	        	   if(location.indexOf("?")==-1){
	        		   location=location+"?lang=en" ;
	        	   }else{
	        		   location=location+"&lang=en" ;
	        	   }
	           }
			   window.location=location;
		   }else{
			   var location = WEBAPP+"views/index.jsp" ;
			   if(lang=="zh"){
	                 location=location+"?lang=zh" ;
               }
			   window.location=location;
		   }		   
	   });
});